package com.zsh.wx_account1.controller;

import com.zsh.wx_account1.util.HttpUtil;
import com.zsh.wx_account1.util.TokenUtil;
import org.junit.jupiter.api.Test;

/**
 * 测试模板消息
 * @Author ZhaoShuHao
 * @Date 2023/8/25 9:28
 */
public class TestModelMessage {
    //测试设置所属行业（模版消息的前置条件）
    @Test
    public void testSetTrade(){
        String url = String.format("https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token=%s", TokenUtil.getAccessToken());
        String data = "{\n" +
                "    \"industry_id1\":\"1\",\n" +
                "    \"industry_id2\":\"4\"\n" +
                "}";
        String s = HttpUtil.doPost(url, data, "application/x-www-form-urlencoded");
        System.out.println(s);
    }
    //测试查询所属行业
    @Test
    public void testGetTrade(){
        String url = String.format("https://api.weixin.qq.com/cgi-bin/template/get_industry?access_token=%s",TokenUtil.getAccessToken());
        System.out.println(HttpUtil.doGet(url));
    }
    //获取模版列表
    @Test
    public void testGetModelMessage(){
        String url = String.format("https://api.weixin.qq.com/cgi-bin/template/get_all_private_template?access_token=%s", TokenUtil.getAccessToken());
        String s = HttpUtil.doGet(url);
        System.out.println(s);
    }


    //测试发送模版消息
    @Test
    public void testModelmessage(){
        String url = String.format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=%s", TokenUtil.getAccessToken());
         /*  String data = "{\n" +
                "           \"touser\":\"okuVs5iLGbRWwjjotu8EsKVURyDM\",\n" +
                "           \"template_id\":\"EOlNyURgdR1rnZx3_x_k9iHb4j5CZ3dshCZxZbCsU1w\",\n" +
                "           \"url\":\"https://blog.csdn.net/ZhShH0413?spm=1010.2135.3001.5343\",\n" +
                "           \"data\":{\n" +
                "                   \"keyword1\": {\n" +
                "                       \"value\":\"张三，恭喜您报名比赛成功\"\n" +
                "                   },\n" +
                "                   \"keyword2\":{\n" +
                "                       \"value\":\"A队\"\n" +
                "                   },\n" +
                "                   \"keyword3\": {\n" +
                "                       \"value\":\"2023年8月26日 7:00\"\n" +
                "                   },\n" +
                "                   \"keyword4\": {\n" +
                "                       \"value\":\"XX集团东大门\"\n" +
                "                   },\n" +
                "                   \"keyword5\": {\n" +
                "                       \"value\":\"A队1人，B队66人\"\n" +
                "                   },\n" +
                "                   \"keyword6\":{\n" +
                "                       \"value\":\"点击链接有惊喜，双击关注666\"\n" +
                "                   }\n" +
                "           }\n" +
                "       }";*/
        String data = "{\n" +
                "\t\"data\":{\n" +
                "\t\t\"CONTENT\":{\n" +
                "\t\t\t\"color\":\"\",\n" +
                "\t\t\t\"value\":\"通知通知通知通知通知\"\n" +
                "\t\t}\n" +
                "\t},\n" +
                "\t\"template_id\":\"gDN9OJDU4aXG0I4jbwww-6RFjS3YLMs8cHG8bJSpdU0\",\n" +
                "\t\"touser\":\"okuVs5iLGbRWwjjotu8EsKVURyDM\"\n" +
                "}";
        System.out.println(HttpUtil.doPost(url, data,"application/x-www-form-urlencoded"));
    }



}
